﻿package com.tvein.sanguo.swc.prompt
{
	//flash
	import flash.display.MovieClip;
	import flash.utils.Timer;
	import flash.events.TimerEvent;
	import flash.events.Event;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	//A3D
	//custom
	import com.tvein.sanguo.swc.common.SwcEvent;
//
	
	public class PromptShell extends MovieClip
	{
		public static const NAME:String = "PromptShell";
		
		private var gameConfig:Array;
		
		public function PromptShell(configArray:Array)
		{
			stage?init(null):addEventListener(Event.ADDED_TO_STAGE, init);
			
			gameConfig = configArray;
		}
		
		private function init(evt:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE , init);
			addEventListener(Event.REMOVED_FROM_STAGE, _onRemoved);

			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.BOTTOM_LEFT;
			stage.addEventListener(Event.RESIZE, _resizeUI);
			
			txtInfo.selectable = false;
			
			_resizeUI();
		}

		public function setInfo(Info:String):void
		{
			txtInfo.htmlText = Info;
			
			var checkTimer:Timer = new Timer(5000);
			checkTimer.addEventListener(TimerEvent.TIMER, _clearInfo);
			checkTimer.start();
		}
		
		private function _clearInfo(evt:TimerEvent):void
		{
			txtInfo.text = "";
			evt.target.stop();
		}
		
		private function _onRemoved(evt:Event):void
		{
			removeEventListener(Event.REMOVED_FROM_STAGE, _onRemoved);
			stage.removeEventListener(Event.RESIZE, _resizeUI);
		}
		
		private function _resizeUI(evt:Event = null):void
		{			
			txtInfo.y = 50;
			
			txtInfo.width = stage.stageWidth;
		}
	}
}